<?php
function skin_dir() {
	global $db_prefix;
	$query = "SELECT value FROM `$db_prefix"."main` WHERE `option` = 'skin'";
	$result = mysql_query($query);
	while($row = mysql_fetch_row($result)) { 
		$dir = "themes/$row[0]";
		return $dir; 
	}
}
function li_skin() {
	global $db_prefix;
	$dir = skin_dir();
	if(file_exists($dir)) {
	include("$dir/index.php");
	}
	else { echo 'Your current theme is not installed correctly!  Go to the <a href="./cp">control panel</a> and choose a different theme.'; }
}
function get_skins() {
	$dir = '../themes';
    $handle = opendir($dir);
    while ($file = readdir($handle)) {
    if(empty($file)) {echo "No other themes installed";}
    else {
		if ($file == "." || $file == ".." || $file == current_skin() || $file == "index.html") { }
		else {
			include("$dir/$file/info.php");
			print "<div class=\"skinlink\"><a href=\"?choose=$file\">$theme_name $version by $author</a></div>\n"; 
		}  
    }
    }
    closedir($handle);
	return $result;
}
function current_skin() {
	global $db_prefix;
	$query = "SELECT value FROM `$db_prefix"."main` WHERE `option` = 'skin'";
	$result = mysql_query($query);
	while($row = mysql_fetch_row($result)) { return $row[0]; }
}
function skin_descript() {
	if(file_exists("../".skin_dir()."/info.php")) { 
	include("../".skin_dir()."/info.php");
	echo "$theme_name $version by <a href=\"$link\">$author</a>";
	}
	else {ec("Current theme not found");}
}
/*
[01:27:36] GreyFox: CAPTAIN COMMAND GIVE YOU ORDER!
[01:27:43] GreyFox: PICK YOU ROOM UP!
[01:27:51] Tallain:  Done
[01:28:48] GreyFox: EAT LOTS OF BROKOLI!
[01:28:55] Tallain:  And done
[01:28:57] Tallain:  =D
[01:29:00] Tallain:  :{)
[01:29:04] GreyFox: HA
[01:29:16] GreyFox: CAPTAIN COMMAND LAUGH AT MOOSETASH
*/
?>